package interfaz;

import java.util.ArrayList;
import processing.core.*;
import java.util.Iterator;
import saito.objloader.OBJModel;



public class Main extends PApplet {

    private float a;
    private int deltatranslate = 15;
    private float crotx, croty, crotz;
    private int radiusphere = 50;
    OBJModel bot;
    private float rotY;
    private float rotX;
    private float posX;
    private float posY;

    public Main() {
    }

    public static void main(String[] args) {
        PApplet.main(new String[]{"interfaz.Main"});
    }

    private void setLight() {
        directionalLight(51, 102, 126, 0, 0, -1);
        lightSpecular(204, 204, 204);
    }

    @Override
    public void setup() {

        bot = new OBJModel(this, "cassini.obj", "absolute", TRIANGLES);
        //bot.enableDebug();
        size(800, 600, P3D);
        background(129);

        pushMatrix();
        translate(width / 2, height / 2, 0);
        bot.scale(5);

        bot.draw();
        popMatrix();
    }

    @Override
    public void draw() {
        background(32);
        noStroke();
        noFill();
        lights();

        pushMatrix();
        translate(width / 2 + posX, height / 2 + posY, 0);
        rotateX(rotY);
        rotateY(rotX);

        bot.draw();

        popMatrix();
    }
    boolean bTexture = true;
    boolean bStroke = false;

    @Override
    public void keyPressed() {
        if (key == 't') {
            if (!bTexture) {
                bot.enableTexture();
                bTexture = true;
            } else {
                bot.disableTexture();
                bTexture = false;
            }
        }
        if (key == 's') {
            if (!bStroke) {
                stroke(255);
                bStroke = true;
            } else {
                noStroke();
                bStroke = false;
            }
        }
    }

    @Override
    public void mouseDragged() {
        rotX += (mouseX - pmouseX) * 0.01;
        rotY -= (mouseY - pmouseY) * 0.01;
    }

    public void keyReleased() {
    }

    @Override
    public void mousePressed() {
    }

    @Override
    public void mouseReleased() {
    }
}
